package com.nav.rummy.core;
public enum Rank {
	DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE;
	public Rank nextInSequence() {
		switch (this) {
		case DEUCE:
			return THREE;
		case THREE:
			return FOUR;
		case FOUR:
			return FIVE;
		case FIVE:
			return SIX;
		case SIX:
			return SEVEN;
		case SEVEN:
			return EIGHT;
		case EIGHT:
			return NINE;
		case NINE:
			return TEN;
		case TEN:
			return JACK;
		case JACK:
			return QUEEN;
		case QUEEN:
			return KING;
		case KING:
			return ACE;
		case ACE:
			return DEUCE;
		}
		return null;
	}

	public int getPoints() {
		switch (this) {
		case DEUCE:
			return 2;
		case THREE:
			return 3;
		case FOUR:
			return 4;
		case FIVE:
			return 5;
		case SIX:
			return 6;
		case SEVEN:
			return 7;
		case EIGHT:
			return 8;
		case NINE:
			return 9;
		}
		return 10;
	}

	public static Rank getInstance(char r) {
		switch (r) {
		case 'A':
			return ACE;
		case '1':
			return ACE;
		case '2':
			return DEUCE;
		case '3':
			return THREE;
		case '4':
			return FOUR;
		case '5':
			return FIVE;
		case '6':
			return SIX;
		case '7':
			return SEVEN;
		case '8':
			return EIGHT;
		case '9':
			return NINE;
		case 'T':
			return TEN;
		case 'J':
			return JACK;
		case 'Q':
			return QUEEN;
		case 'K':
			return KING;
		}
		return null;
	}

	public char toChar() {
		switch (this) {
		case ACE:
			return 'A';
		case DEUCE:
			return '2';
		case THREE:
			return '3';
		case FOUR:
			return '4';
		case FIVE:
			return '5';
		case SIX:
			return '6';
		case SEVEN:
			return '7';
		case EIGHT:
			return '8';
		case NINE:
			return '9';
		case TEN:
			return 'T';
		case JACK:
			return 'J';
		case QUEEN:
			return 'Q';
		case KING:
			return 'K';
		}
		return ' ';
	}
}
